<?php
class Zend_View_Helper_Nicedate extends Zend_View_Helper_Abstract{
    private $_config;
    
    public function nicedate($date){
        if(is_string($date))$date = new \DateTime($date);

        if($date instanceof \DateTime){
            $today = new \DateTime("now");
            $interval = $date->diff($today);

            $hours_min = $date->format('H:i');
            if($hours_min=='00:00')$hours_min='';
            switch($interval->format('%a')){
                case 0:
                    $date_text = $hours_min?:'Сегодня';
                break;
                case 1:
                    $date_text = 'Вчера '.$hours_min;
                break;
                case 2:
                    $date_text = 'Позавчера '.$hours_min;
                break;
                default:
                    $date_text = $date->format('Y-m-d');
                break;
            }
            return $date_text;
        }
    }
}